package com.health.home.controller;

import com.alibaba.nacos.api.model.v2.Result;
import com.health.home.domain.po.TnewImagePo;
import com.health.home.service.TnewImageServcie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author xpz
 * @date 2024/12/16 11:32
 */
@RestController
@RequestMapping("/newImage")
public class TnewImageController {

    @Autowired
    private TnewImageServcie tnewImageServcie;

    /**
     * 查询图片资讯列表
     */
    @GetMapping("/newImageList")
    public Result<List<TnewImagePo>> newImageList(){
        List<TnewImagePo> list = tnewImageServcie.list();
        return Result.success(list);
    }

    /**
     * 新增图片资讯
     */
    @PostMapping("/newImageAdd")
    public Result newImageAdd(@ModelAttribute TnewImagePo tnewImagePo){
         tnewImageServcie.save(tnewImagePo);
        return Result.success(tnewImagePo);
    }

    /**
     * 删除图片资讯
     */
    @PostMapping("/newImageDel")
    public Result newImageDel(Integer id){
        boolean removeById = tnewImageServcie.removeById(id);
        return Result.success(removeById);
    }

    /**
     * 更新图片资讯
     */
    @PostMapping("/newImageUpdate")
    public Result newImageUpdate(@ModelAttribute TnewImagePo tnewImagePo){
        tnewImageServcie.updateById(tnewImagePo);
        return Result.success(tnewImagePo);
    }

}
